package code.lewdy.lottery;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import code.lewdy.util.FormatUtil;

/**合买记录
 * @author Administrator
 *BetRecord.id in(select betId from UnionBuyRecord where ownerId=Member.id) 
 */
@Entity
@Table
public class UnionBuyRecord {
	private Long id;
	private String orderId; //订单id,同投注id
	private Long unionSetId; //合买设置id
	private Long betId;  //投注id
	private Long ownerId; //购买人
	private String ownerName;
	private int buyCount; //购买份数
	private double partPrice; //单价
	private int isPay; //是否派奖
	private double winAmount; //中奖金额
	private Date createDate;
	
	@Id
	@GeneratedValue
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	@Column(length=30)
	public String getOrderId() {
		return orderId;
	}
	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}
	public Long getUnionSetId() {
		return unionSetId;
	}
	public void setUnionSetId(Long unionSetId) {
		this.unionSetId = unionSetId;
	}
	public Long getOwnerId() {
		return ownerId;
	}
	public void setOwnerId(Long ownerId) {
		this.ownerId = ownerId;
	}
	@Column(length=30)
	public String getOwnerName() {
		return ownerName;
	}
	public void setOwnerName(String ownerName) {
		this.ownerName = ownerName;
	}
	public int getBuyCount() {
		return buyCount;
	}
	public void setBuyCount(int buyCount) {
		this.buyCount = buyCount;
	}
	public double getPartPrice() {
		partPrice = FormatUtil.formatDecimal(partPrice, 2);
		return partPrice;
	}
	public void setPartPrice(double partPrice) {
		this.partPrice = partPrice;
	}
	public int getIsPay() {
		return isPay;
	}
	public void setIsPay(int isPay) {
		this.isPay = isPay;
	}
	public double getWinAmount() {
		winAmount = FormatUtil.formatDecimal(winAmount, 2);
		return winAmount;
	}
	public void setWinAmount(double winAmount) {
		this.winAmount = winAmount;
	}
	@Temporal(TemporalType.TIMESTAMP)
	public Date getCreateDate() {
		return createDate;
	}
	@Transient
	public String getDate(){
		return FormatUtil.formatDate(createDate, "yyyy-MM-dd HH:mm:ss");
	}
	public void setCreateDate(Date creatDate) {
		this.createDate = creatDate;
	}
	public void setBetId(Long betId) {
		this.betId = betId;
	}
	public Long getBetId() {
		return betId;
	}
}
